package com.auto.survey.util.monitoring.dao

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import com.auto.survey.util.monitoring.entity.NonCompliantPoint

@Dao
interface NonCompliantPointDao {

    // 插入单个不符合点
    @Insert(onConflict = OnConflictStrategy.Companion.REPLACE)
    suspend fun insert(point: NonCompliantPoint): Long

    // 插入多个不符合点
    @Insert(onConflict = OnConflictStrategy.Companion.REPLACE)
    suspend fun insertAll(points: List<NonCompliantPoint>): List<Long>

    // 根据计算结果ID查询所有不符合点
    @Query("SELECT * FROM NonCompliantPoint WHERE calculationResultId = :resultId")
    suspend fun getByResultId(resultId: Long): List<NonCompliantPoint>

    // 删除指定计算结果的所有不符合点
    @Query("DELETE FROM NonCompliantPoint WHERE calculationResultId = :resultId")
    suspend fun deleteByResultId(resultId: Long): Int
}